<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>节点优化</title>
</head>
<body>
    <script>
        for(var i=0; i < 10; i++){
            var p = document.createElement('p')
            p.innerHTML = i
            document.body.appendChild(p)
        }

        // 优化  
        const el = document.createDocumentFragment()
        for(var i=0; i < 10; i++){
            var p1 = document.createElement('p')
            p1.innerHTML = i
            el.appendChild(p1)
        }
        document.body.appendChild(el)
    </script>
</body>
</html>